package manager.com.ithei.edu.info.manager.domain;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Person {
    private String sid;
    private String name;
    private String age;
    private String birthday;
    private String address;

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Person() throws ParseException {
    }

    @Override
    public String toString() {
        return this.sid+","+this.name+","+this.age+","+this.birthday+","+this.address;
    }

    public Person(String sid, String name, String age, String birthday, String address) throws ParseException {
        this.sid = sid;
        this.name = name;
        this.age = age;
        this.birthday = birthday;
        this.address = address;
    }

    public void show(){
        System.out.println(this.name+"\t\t"+this.sid+"\t\t"+this.age+"\t\t"+this.birthday+"\t\t"+this.address+"\t\t");
    }

    public Person(String sid, String name, String birthday, String address) throws ParseException {
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        String agee=String.valueOf(new Date().getYear()-sdf.parse(birthday).getYear());
        this.sid = sid;
        this.name = name;
        this.birthday = birthday;
        this.address = address;
        this.age=agee;
    }
}
